package com.jiaeda.springsecurity.validate.code;

import lombok.Getter;
import lombok.Setter;

import java.awt.image.BufferedImage;
import java.time.LocalDateTime;

/**
 * Created by chengchaopeng on 2018/7/10.
 */
@Getter
@Setter
public class ValidateCode {
    //验证码图片
    private BufferedImage image;
    //验证码编码
    private String code;
    //到期时间
    private LocalDateTime expireTime;

   public ValidateCode(BufferedImage image, String code, int seconds){
        this.image=image;
        this.code=code;
        this.expireTime=LocalDateTime.now().plusSeconds(seconds);
    }

    /**
     * 验证码是否已经过期
     * @return
     */
    public boolean isExpried() {
        return LocalDateTime.now().isAfter(expireTime);
    }
}
